package org.example.sec03;

import com.seaway.models.sec03.Person;
import org.example.sec02.ProtoDemo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class ProtoDemo03 {
    private static final Logger LOG = LoggerFactory.getLogger(ProtoDemo03.class);
    private static final Path PATH = Path.of("person.out");

    public static void main(String[] args) throws IOException {
        print().writeTo(Files.newOutputStream(PATH));
        Person person = Person.parseFrom(Files.newInputStream(PATH));
        System.out.println(person);
        System.out.println(print().equals(person));
        System.out.println(person.toByteArray().length);

    }
    private static Person print() {
        var huran = Person.newBuilder()
                .setLastName("huran")
                .setAge(12)
                .setEmail("@qq.com")
                .setEmployed(true)
                .setSalary(232.3434)
                .setBankAccountNumber(23232323L)
                .setBalance(-2323)
                .build();
        return huran;
    }
}
